// 文章接口模块
import { request } from '@/utils/request.js'

/*
 * 获取频道文章列表
 * @params channel_id 频道ID
 * @params timestamp 时间戳(请求第一页数据:传当前时间戳; 请求历史数据: 传返回回来的时间戳)
 */
export const getArticles = params => request({
  method: 'get',
  url: '/v1_0/articles',
  params
})

/*
 * 获取文章详情
 * @params articleId 文章ID
 */
export const getArticleById = articleId => request({
  method: 'get',
  url: `/v1_0/articles/${articleId}`
})

/**
 * 收藏文章
 * @params 文章id
*/
export const addCollect = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

/**
 * 取消收藏文章
 * @params 文章id
*/
export const deleteCollect = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`
  })
}

/**
 * 点赞文章
 * @params 文章id
 */
export const addLike = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}

/**
 * 取消点赞文章
 * @params 文章id
 */
export const deleteLike = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${target}`
  })
}
